package com.zdwl.controller;

import com.zdwl.pojo.Menu;
import com.zdwl.utils.JsonResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;

/**
 * Author: Professor_Kong
 * date: 2019/2/28
 */

@RestController
public class MenuController {


    @RequestMapping(value = "/getMenu",method = RequestMethod.GET)
    public JsonResult getMenu(){

        JsonResult jsonResult = new JsonResult();

        ArrayList arrayList = new ArrayList();
        //一级
        Menu menu = new Menu();
        menu.setId(1);
        menu.setMenuName("一级跳转");
        menu.setUrl("www.baidu.com");
        arrayList.add(menu);

        //二级子1
        Menu menu0 = new Menu();
        menu0.setId(21);
        menu0.setMenuName("用户管理");
        menu0.setUrl("www.baidu.com");
        //二级子2
        Menu menu1 = new Menu();
        menu1.setId(22);
        menu1.setMenuName("二级子菜单2");
        menu1.setUrl("www.baidu.com");

        ArrayList arrayList1 = new ArrayList();
        arrayList1.add(menu0);
        arrayList1.add(menu1);

        //二级父
        Menu menu2 = new Menu();
        menu2.setId(2);
        menu2.setMenuName("模拟数据");
        menu2.setUrl("");
        menu2.setChildren(arrayList1);

        arrayList.add(menu2);


        for(int i = 3 ; i <6 ; i ++){
            Menu menu5 = new Menu();
            menu5.setId(i*10+1);
            menu5.setMenuName("二级子菜单"+i+"-1");
            menu5.setUrl("www.baidu.com");
            //二级子2
            Menu menu6 = new Menu();
            menu6.setId(i*10+2);
            menu6.setMenuName("二级子菜单"+i+"-2");
            menu6.setUrl("www.baidu.com");

            ArrayList arrayList2 = new ArrayList();
            arrayList2.add(menu5);
            arrayList2.add(menu6);

            Menu menu7 = new Menu();
            menu7.setId(i);
            menu7.setMenuName("二级菜单"+i);
            menu7.setChildren(arrayList2);

            arrayList.add(menu7);
        }

        jsonResult.setData(arrayList);
        return jsonResult;
    }
}
